123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <!-- 头部 -->
- <templateHead></templateHead>
- <!-- 菜单 -->
- <templateMenu></templateMenu>
- <!-- 内容 -->
- <div v-for="(item,index) in templateData" :key="index">
- <!--广告组件-->
- <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag" v-if="item.sectorName=='adSector'"></templateAd>
- <!--列表组件-->
- <templateList :skinId="skinId" :templateData="item.componentList" :routeId="routeId" :pageData="pageData" :newsList="newsList" v-if="item.sectorName=='fixedListSector'"></templateList>
- </div>
- <!-- 底部 -->
- <templateFoot></templateFoot>
- </template>
- <script setup>
- //0.加载全局模板组件 start---------------------------------------->
- //0.1全局通栏
- import templateHead from '@/components/template/sector/head/1200x200/1.vue'
- import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
- import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
- //0.2局部通栏
- //0.2.1广告组件
- import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
- //0.2.2列表组件
- import templateList from '@/components/template/sector/body/list/list/1200x1220/1.vue'
- //0.加载全局模板组件 end---------------------------------------->
- //1.获得基本信息单元 start---------------------------------------->
- //1.1获得页面依赖
- import { ref, onMounted } from 'vue';
- //1.2使用url查询导航池id
- const targetSegment = getRoutePath(1);//当前页面的url路径 这是第一层 所以获得域名后面的第一层url
- const routeId = ref("");//当前url路径代表的cid
- const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment,
- },
- });
- if (getRouteId.code == 200) {
- routeId.value = getRouteId.data.category_id
- }
- //1.3获得pinia源
- import { useTemplateBaseStore } from '@/stores/templateBase'
- const templateBaseStore = useTemplateBaseStore()
- //1.4获得该页的皮肤id - 在每个组件中也是同样的获得方法
- const skinId = ref("")
- const websiteId = ref("")
- //1.5获得站点基本信息
- const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
- method: 'GET',
- query: {
- 'link_textnum':24,
- 'link_imgnum':18,
- 'link_footnum':4
- },
- });
- if (responseStatus.code == 200) {
- //1.6.1设置站点基本信息
- templateBaseStore.setWebSiteInfo(responseStatus.data)
- websiteId.value = responseStatus.data.website_head.id;//获得网站id
- //1.6.2设置皮肤id
- skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
- }
- //1.6.seo
- const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
- method: 'GET',
- query: {
- 'catid': routeId.value
- },
- });
- let seoTitle = setData.data.seo_title;
- let seoDescription = setData.data.seo_description;
- let seoKeywords = setData.data.seo_keywords;
- let seoSuffix = setData.data.suffix;
- let seoName = setData.data.website_name;
- useSeoMeta({
- title: seoTitle + "_" + seoSuffix,
- meta: [
- { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
- ]
- });
- //1.获得基本信息单元 end---------------------------------------->
- //2.页面数据 start---------------------------------------->
- //2.1获得页面模板数据
- const response = await requestDataPromise('/client/indexData', {
- method: 'POST',
- body: {
- 'website_id':websiteId.value,
- 'getpage':'index'
- },
- });
- //页面模板数据
- const templateData = response.data.template.list;
- console.log(templateData)
- //2.2广告数据
- const adData = ref([]);
- adData.value.push(response.data.ad.top)
- for(let item of response.data.ad.list){
- adData.value.push(item)
- }
- templateBaseStore.setAdList(adData.value)
- //2.3分页数据
- const route = useRoute();
- let pageNum = ref(1); //当前页码
- pageNum.value = parseInt(route.params.id);//路由中传递的分页页码
- let total = ref(100); //总条数
- let pageSize = ref(20); //每页条数
- //3.1新闻列表数据
- const newsList = ref([]);
- let newslists = async () => {
- const listData = await requestDataPromise('/web/getWebsiteArticleList', {
- method: 'GET',
- query: {
- 'page': pageNum.value,
- 'pageSize': pageSize.value,
- 'catid': routeId.value
- },
- });
- console.log(listData)
- if (listData.code == 200) {
- newsList.value = listData.data.rows;
- pageData.value.total = listData.data.count;
- }
- }
- newslists();
- let pageData = ref({
- "pageNum": pageNum.value,
- "pageSize": pageSize.value,
- "total": total.value
- });
- //2.页面数据 end---------------------------------------->
- </script>
- <style lang="less" scoped>
- @import url('@/assets/css/list.less');
- </style>
|